package cn.kn.triage.sys.controller;

import cn.kn.triage.common.model.R;
import cn.kn.triage.sys.service.PermissionService;
import cn.kn.triage.sys.vo.RolePerm;
import org.springframework.web.bind.annotation.*;

/**
 * @author yinzn
 * @create 2020-10-18 14:22
 */
@RestController
@CrossOrigin
@RequestMapping("sys/perm")
public class PermiddionController {
    private final PermissionService permissionService;

    public PermiddionController(PermissionService permissionService) {
        this.permissionService = permissionService;
    }

    @GetMapping("right")
    public R right(){
        return permissionService.right();
    }

    @GetMapping("/{roleId}")
    public R getIdsByRoleId(@PathVariable Integer roleId){
        return permissionService.getIdsByRoleId(roleId);
    }

    @PostMapping("/saveRight/{roleId}")
    public R saveRight(@PathVariable Integer roleId, @RequestBody RolePerm[] rolePerms){
        return permissionService.saveRight(roleId,rolePerms);
    }


}
